from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
import time
import json

with open("cookies.json", "r") as f:
    cookies = json.load(f)


options = Options()
#options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(options, service)



link = "https://i.cuc.edu.cn/"

driver.get(link)

driver.delete_all_cookies()

for cookie in cookies:
    cookie_dict = {
        "domain": ".cuc.edu.cn",
        "name": cookie["name"],
        "value": cookie["value"],
        "path": "/",
        "expires": "",
        "httpOnly": False,
        "Secure": False,
        "HostOnly": False
    }
    driver.add_cookie(cookie_dict)

driver.refresh()

time.sleep(20)

element_list = driver.find_elements(By.XPATH, '//*[@id="pane-card_0"]/div/div/div/div[1]/div/div/div/div[1]/div[1]/div[1]/ul/li[1]/div')
for element in element_list:
    print(element)

time.sleep(10)
#element_list = driver.find_elements(By.XPATH, "//*[@id='cms_content']/div/div[2]/div[1]/span")

#for element in element_list:
#     print(element.text)